MALL
JAVA PO
January 16,
2006
Instructions for Chameneos source
code
--------------------------------------
The file p_chameneos.adb contains the Ada procedure P_Chameneos
illustrating some peer to peer synchronization problems
It can be run by entering the following Unix shell commands :
gnatmake p_chameneos.adb
./p_chameneos
This directory contains 10 files which are Ada library units:
p_chameneos.adb
p_id_chameneos.ads
mall.adb
this version must replace the one given in the code directory. This is
the implementation simulating Java with a protected object
mall.ads
generic_lock.adb
generic_lock.ads
p_colour.adb
p_colour.ads
protected_machine.adb
protected_machine.ads
--------------------------------------
About this version
--------------------------------------
This MALL JAVA PO version is simulating Java semantics
----------------------
This implementation is safe since Java like implementation is defensive
using MustWait
MustWait forbids a newcommer to overcome the waiting partner
This version of the mall is implemented with a protected object named
Cooperation_Synchro.
The Java wait operation is here an entry call with a barrier named
NotifyAll
The Java synchronized method is simulated by Cooperation_Synchro
Score is an in out parameter indicating the stage reached by the caller
Score = 0 is the first request
Score = 1 when the first partner has registered and waits for the
arrival of the second
Score = 2 when the partner Id is returned
Data are used to record the history of the server behaviour
First_Call : Boolean :=
True; -- when the call
is the first call of a pair of Chameneos
MustWait : Boolean := True;
-- Java defensive programming forbidding a newcommer to overcome the
waiting partner
A_Chameneos : Id_Chameneos; -- name of the first visitor
B_Chameneos : Id_Chameneos; -- name of the second visitor
MustWait forbids the
execution of the entry Cooperate by a third visitor until the
first visitor which has been requeued to the entry Wait has got the
monitor lock and registered the name of its partner.